<template>
    <view>
        <view class="header-nav">
            <view class="left-btn" @click="goBack">
                <uni-icon type="arrowleft" size="24" style="font-size:52upx" color="#007aff"></uni-icon>
                <view style="color:#007aff">取消</view>
            </view>
            <view>添加规则</view>
            <view style="margin-top:24upx;margin-right:16upx;">
                <button type="primary" size="mini" style="font-size: 24upx;">完成</button>
            </view>
        </view>

        <view>
            <view>
                <form @submit="formSubmit" @reset="formReset">
                    <view class="uni-form-item" style="color:#999999;">
                        基础规则
                    </view>
                    <view class="uni-form-item">
                        <view class="title">规则名称</view>
                        <input class="uni-input" name="ruleName" type="text" placeholder="规则名称" v-model="inputValue"
                            @input="onKeyInput" />
                    </view>

                    <view class="uni-form-item">
                        <view class="title">播放日期</view>

                        <!-- <view class="flex1">
                            <picker mode="date" :value="start_date" :start="start_date" :end="other"  @change="bindDateChange">
                                <view class="date">{{start_date}}</view>
                            </picker>
                        </view>

                        <view class="flex1">
                            <picker mode="date" :value="start_date" :start="start_date" @change="bindDateChange2">
                                <view class="date">{{other}}</view>
                            </picker>
                        </view>
                 -->

                        <view style="display:flex;">
                            <view @click="open1">{{startTime}}&nbsp;---</view>
                            <view @click="open2">&nbsp;{{endTime}}</view>
                        </view>

                        <uni-calendar ref="calendar1" :lunar="true" :insert="false" disable-before="false"
                            @confirm="confirm1" />
                        <uni-calendar ref="calendar2" :lunar="true" :insert="false" disable-before="false"
                            @confirm="confirm2" />
                    </view>

                    <view class="uni-form-item">
                        <view class="title">播放时间</view>
                        <!-- <picker mode="multiSelector" :range="time" @change="timeChange">
                            <view> {{  time[0]?time[0][timeIndex1]:'00:00' }} ---
                                {{ time[1]?time[1][timeIndex2]:'00:00'  }}</view>
                        </picker> -->


                        <picker :range="aaa1" @change="aChange">
                            {{ aaa1[aaaIndex1]?aaa1[aaaIndex1]:'开始时间' }}---
                        </picker>

                        <picker :range="aaa2" @change="aChange2">
                            {{ aaa2[aaaIndex2]?aaa2[aaaIndex2]:'结束时间' }}
                        </picker>


                        <!-- <view :value="pickerTime" @click="showMulPicker">{{pickerTime}}</view>
                        <mpvue-picker themeColor="#8D0177" ref="mpvueTimePicker" :mode='mode'
                            :pickerValueDefault='timePickerValueDefault' 
                            :pickerValueArray='timePickerValueArray' 
                            @onConfirm="onConfirm">
                        </mpvue-picker> -->
                    </view>

                    <view class="uni-form-item">
                        <view class="title">播放区域</view>
                        <view :value="pickerLocation" @click="showMulLinkageThreePicker">{{pickerLocation}}</view>
                        <mpvue-city-picker themeColor="#8D0177" ref="mpvueCityPicker" :mode='mode' name="bbbbbb"
                            :pickerValueDefault="cityPickerValueDefault" @="" @onConfirm="onConfirm">
                        </mpvue-city-picker>
                    </view>

                    <view class="uni-form-item">
                        <view class="title">播放上限</view>
                        <input class="uni-input" name="upperlimit" type="number" placeholder="每日播放上限" />
                    </view>

                    <view class="uni-form-item">
                        <view class="title">广告词</view>
                        <input class="uni-input" name="advertisingWords" type="text" placeholder="显示与资源下方的广告词" />
                    </view>

                    <view class="uni-form-item">
                        <view class="title">备注信息</view>
                        <input class="uni-input" name="remarks" type="text" placeholder="规则备注信息" />
                    </view>

                    <view class="uni-form-item">
                        <view class="title">推广码</view>
                        <switch type="switch" @change="codeSwitchChange" style="height:0;margin-top:-16upx;"
                            name="generalizationCode" />
                    </view>


                    <view v-if="isCode===true">
                        <view class="uni-form-item">
                            <view class="title">推广链接</view>
                            <input class="uni-input" name="code1" type="text" placeholder="推广码的链接地址" />
                        </view>

                        <view class="uni-form-item">
                            <view class="title">推广说明</view>
                            <input class="uni-input" name="code2" type="text" placeholder="推广码的信息说明" />
                        </view>

                        <view class="uni-form-item">
                            <view class="title">推广奖励</view>
                            <input class="uni-input" name="code3" type="text" placeholder="推广码的扫码奖励/元" />
                        </view>

                        <view class="uni-form-item">
                            <view class="title">购买奖励</view>
                            <input class="uni-input" name="code4" type="text" placeholder="推广码的下单奖励/元" />
                        </view>
                    </view>




                    <view class="uni-form-item" style="color:#999999;">
                        精准投放
                    </view>

                    <view class="uni-form-item">
                        <view class="title">所属行业</view>
                        <view class="uni-list-cell-db">
                            <picker name="industry" @change="bindPickerChange" mode=selector :value="index"
                                :range="array">
                                <view class="uni-input">{{ array[index] }}</view>
                            </picker>
                        </view>
                        <switch type="checkbox" checked style="margin-left:280upx;" @change="excludeSwitchChange" />排斥

                       
                        
                    </view>

                    <view class="uni-form-item">
                        <view class="title">区域设置</view>
                        <view class="location-row">
                            <view class="location-item" :class="location==='不限'?'location-active':''"
                                @tap="toLocation('不限')">不限</view>
                            <view class="location-item" :class="location==='商圈'?'location-active':''"
                                @tap="toLocation('商圈')">商圈</view>
                            <view class="location-item" style="border:none"
                                :class="location==='地铁站'?'location-active':''" @tap="toLocation('地铁站')">地铁站</view>
                        </view>
                    </view>

                    <view class="uni-form-item" style="border:1px solid #999999;margin:0 20upx;border-radius: 16upx;">
                        <view v-if="location==='不限'">
                            <checkbox-group @change="checkboxChange1">
                                <label v-for="item in items1" :key="item.value" class="checkbox-label">
                                    <view class="checkbox-name">
                                        <view>
                                            <checkbox :value="item.value" :checked="item.checked" />
                                        </view>
                                        <view>{{item.name}}</view>
                                    </view>

                                </label>
                            </checkbox-group>
                        </view>
                        <view v-else-if="location==='商圈'">
                            <checkbox-group @change="checkboxChange2">
                                <label v-for="item in items2" :key="item.value" class="checkbox-label">
                                    <view class="checkbox-name">
                                        <view>
                                            <checkbox :value="item.value" :checked="item.checked" />
                                        </view>
                                        <view>{{item.name}}</view>
                                    </view>

                                </label>
                            </checkbox-group>
                        </view>
                        <view v-else-if="location==='地铁站'">
                            <checkbox-group @change="checkboxChange1">
                                <label v-for="item in items1" :key="item.value" class="checkbox-label">
                                    <view class="checkbox-name">
                                        <view>
                                            <checkbox :value="item.value" :checked="item.checked" />
                                        </view>
                                        <view>{{item.name}}</view>
                                    </view>

                                </label>
                            </checkbox-group>
                        </view>
                    </view>

                    <view class="uni-form-item">
                        <view class="title">设备类型</view>
                        <view class="location-row">
                            <view class="location-item" :class="equipmentType==='不限'?'location-active':''"
                                @tap="toEquipmentType('不限')">不限</view>
                            <view class="location-item" :class="equipmentType==='智能电视'?'location-active':''"
                                @tap="toEquipmentType('智能电视')">智能电视</view>
                            <view class="location-item" style="border:none"
                                :class="equipmentType==='机顶盒'?'location-active':''" @tap="toEquipmentType('机顶盒')">机顶盒
                            </view>
                        </view>
                    </view>

                    <view class="uni-form-item" style="border:1px solid #999999;margin:0 20upx;border-radius: 16upx;">
                        <view v-if="equipmentType==='不限'">
                            <checkbox-group @change="checkboxChange1">
                                <label v-for="item in items1" :key="item.value" class="checkbox-label">
                                    <view class="checkbox-name">
                                        <view>
                                            <checkbox :value="item.value" :checked="item.checked" />
                                        </view>
                                        <view>{{item.name}}</view>
                                    </view>

                                </label>
                            </checkbox-group>
                        </view>
                        <view v-else-if="equipmentType==='智能电视'">
                            <checkbox-group @change="checkboxChange2">
                                <label v-for="item in items2" :key="item.value" class="checkbox-label">
                                    <view class="checkbox-name">
                                        <view>
                                            <checkbox :value="item.value" :checked="item.checked" />
                                        </view>
                                        <view>{{item.name}}</view>
                                    </view>

                                </label>
                            </checkbox-group>
                        </view>
                        <view v-else-if="equipmentType==='机顶盒'">
                            <checkbox-group @change="checkboxChange1">
                                <label v-for="item in items1" :key="item.value" class="checkbox-label">
                                    <view class="checkbox-name">
                                        <view>
                                            <checkbox :value="item.value" :checked="item.checked" />
                                        </view>
                                        <view>{{item.name}}</view>
                                    </view>

                                </label>
                            </checkbox-group>
                        </view>
                    </view>

                    <view class="uni-form-item">
                        <view class="title">指定商家</view>
                        <input class="uni-input" name="business" type="text" placeholder="商家名称" />
                    </view>

                    <view class="uni-form-item">
                        <view class="title">指定广告机</view>
                        <input class="uni-input" name="advertisingMachine" type="text" placeholder="广告机名称" />
                    </view>


                    <view class="uni-form-item">
                        <view class="title">所属行业</view>
                        <button @click="openPopup">{{industrys}}</button>
                        <uni-popup ref="popup" type="bottom">
                            <view style="display:flex;flex-direction: row;justify-content: space-between;font-size:34upx;">
                                <view style="color:#888888"  @click="closePopup">取消</view>
                                <view style="color:#007aff" @click="okPopup">确定</view>
                            </view>
                            <checkbox-group @change="industryCheckboxChange" style="margin-top:30upx;">
                                    <label v-for="item in industry" :key="item.id" class="checkbox-label">
                                        <view class="checkbox-name">
                                            <view>
                                                <checkbox :value="item.id" :checked="item.checked" />
                                            </view>
                                            <view>{{item.name}}</view>
                                        </view>
    
                                    </label>
                                </checkbox-group>
                                <uni-pagination @change="handlePage" :total="total" :current="pageNum" :pageSize="pageSize"></uni-pagination>
                        </uni-popup>
                    </view>
                   


                    <button form-type="submit">添加完成</button>
                </form>
            </view>
        </view>



    </view>
</template>
<script>

    import uniIcon from "@/components/uni-icon/uni-icon.vue";
    import mpvuePicker from '@/components/mpvue-picker/mpvuePicker.vue';
    import mpvueCityPicker from '@/components/mpvue-citypicker/mpvueCityPicker.vue';
    import cityData from '@/common/city.data.js';
    import uniCalendar from "@/components/uni-calendar/uni-calendar"
    import uniPopup from "@/components/uni-popup/uni-popup.vue"
    import uniPagination from "@/components/uni-pagination/uni-pagination.vue"
    import socket from 'plus-websocket';
    var _self;
    export default {
        components: {
            uniIcon, mpvuePicker,
            mpvueCityPicker, uniCalendar,uniPopup,uniPagination
        },
        data() {
            const currentDate = this.getDate({
                format: true
            })
            return {
                inputValue: '',
                startTime: '开始日期',
                endTime: '结束日期',

                start_date: currentDate,
                end_date: currentDate,
                other: '请输入',

                timeIndex1: 0,
                timeIndex2: 0,
                time: [
                    ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
                    ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00']
                ],


                aaa1: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
                aaaIndex1: -1,
                aaa2: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
                aaaIndex2: -1,
                timePickerValueArray: [
                    [
                        { label: '01:00', value: 1 },
                        { label: '02:00', value: 2 },
                        { label: '03:00', value: 3 },
                        { label: '04:00', value: 4 },
                        { label: '05:00', value: 5 },
                        { label: '06:00', value: 6 },
                        { label: '07:00', value: 7 },
                        { label: '08:00', value: 8 },
                        { label: '09:00', value: 9 },
                        { label: '10:00', value: 10 },
                        { label: '11:00', value: 11 },
                        { label: '12:00', value: 12 },
                        { label: '13:00', value: 13 },
                        { label: '14:00', value: 14 },
                        { label: '15:00', value: 15 },
                        { label: '16:00', value: 16 },
                        { label: '17:00', value: 17 },
                        { label: '18:00', value: 18 },
                        { label: '19:00', value: 19 },
                        { label: '20:00', value: 20 },
                        { label: '21:00', value: 21 },
                        { label: '22:00', value: 22 },
                        { label: '23:00', value: 23 },
                        { label: '00:00', value: 24 }
                    ],
                    [
                        { label: '01:00', value: 1 },
                        { label: '02:00', value: 2 },
                        { label: '03:00', value: 3 },
                        { label: '04:00', value: 4 },
                        { label: '05:00', value: 5 },
                        { label: '06:00', value: 6 },
                        { label: '07:00', value: 7 },
                        { label: '08:00', value: 8 },
                        { label: '09:00', value: 9 },
                        { label: '10:00', value: 10 },
                        { label: '11:00', value: 11 },
                        { label: '12:00', value: 12 },
                        { label: '13:00', value: 13 },
                        { label: '14:00', value: 14 },
                        { label: '15:00', value: 15 },
                        { label: '16:00', value: 16 },
                        { label: '17:00', value: 17 },
                        { label: '18:00', value: 18 },
                        { label: '19:00', value: 19 },
                        { label: '20:00', value: 20 },
                        { label: '21:00', value: 21 },
                        { label: '22:00', value: 22 },
                        { label: '23:00', value: 23 },
                        { label: '00:00', value: 24 }
                    ],
                ],

                 array: ['中国', '美国', '巴西', '日本'],
               
                index: 0,

                mode: 'selector',
                pickerLocation: '选择省/市/区',
                cityPickerValueDefault: [0, 0, 1],// 初始化值

                // pickerTime: '开始时间--结束时间',
                timePickerValueDefault: [1, 1],


                isCode: false,

                location: '商圈',
                items1: [
                    {
                        value: '美国',
                        name: '美国'
                    },
                    {
                        value: '中国',
                        name: '中国',
                        checked: 'true'
                    },
                    {
                        value: '巴西',
                        name: '巴西'
                    },
                    {
                        value: '日本',
                        name: '日本'
                    },
                    {
                        value: '英国',
                        name: '英国'
                    },

                ],
                items2: [
                {
                        value: '美国',
                        name: '美国'
                    },
                    {
                        value: '中国',
                        name: '中国',
                        checked: 'true'
                    },
                    {
                        value: '巴西',
                        name: '巴西'
                    },
                    {
                        value: '日本',
                        name: '日本'
                    },
                ],
                equipmentType: '智能电视',

                // temp: {
                  
                //     name:'',//规则名称
                //     ad_id:'',
                //     ad_name:'',//广告主名称
                //     video_id:'',
                //     video_name:'',
                //     play_time:'',//播放时间段
                //     ad_word:'',//广告词
                //     is_coupon:'',//是否有优惠券：1=有,2=没有
                //     coupon_url:'',//优惠券链接
                //     coupon_explain:'',//优惠券说明
                //     trade_id:'',   //行业id
                //     trade_name:'',//行业名称
                //     region_id:'', //区域id
                //     region_name:'',//区域名称
                //     equipment_code:'',//广告设备编号
                //     equipment_id:'',//广告机id
                //     start_time:'',
                //     end_time:'',
                  
                // },
                industry: [{ id: '',value:'', name: '', checked: false }],
                industrys:'行业',
                total:'',
                pageNum:1,
                type:'next',
                pageSize:12

            }
        },
        onLoad() {
			_self = this;
			_self.industryList()
		},
        methods: {

          
            //行业列表
			industryList() {
				const getTrade = {
					company: 'STQ',
					api: "pc_trade_index",
					version: '1.0',
					data: {
						rows: this.pageSize,
						page: this.pageNum
					}
				};
				socket.sendSocketMessage({
					data: JSON.stringify(getTrade)
				});

				_self.getData()

			},
            handlePage(params){
                this.pageNum=params.current;
                var obj={
                    current:this.pageNum,
                    // type:this.type
                }
                console.log(obj)
                _self.handleMeetingList(obj)

            },
            handleMeetingList(obj){
                this.pageNum=obj.current
                // console.log(this.pageNum)
                _self.industryList() 

            },
            openPopup(){
                this.$refs.popup.open()
            },
            closePopup(){
                this.$refs.popup.close()
                this.industrys="行业"
                var items = this.industry;
                for (var i = 0, len11 = items.length; i < len11; i++) {
                    const item = items[i]
                    items[i].checked=null;   
                    console.log( items[i].checked)
                } 
            },
            okPopup(){
                this.$refs.popup.close()
            },
            industryCheckboxChange(e){
                var items = this.industry,
                    show=[],
                    values = e.detail.value;
                for (var i = 0, len11 = items.length; i < len11; i++) {
                    const item = items[i]
                    if (values.includes(item.id)) {
                        this.$set(item, 'checked', true)
                      
                        // this.industrys=item.name  //只显示最后一个
                        show.push(item.name) //数字
                        console.log(item,item.name,show)
                    } else {
                        this.$set(item, 'checked', false)
                    }
                }
              
                console.log(show)
                 this.industrys=show.toString()
                console.log(this.industrys)
                console.log(e)
            },

            goBack() {
                uni.navigateTo({
                    url: '../advertisement/resourcesDetails'
                });
            },
            onKeyInput: function (event) {
                this.inputValue = event.target.value;
            },
            //picker组件 播放时间函数
            timeChange: function (e) {
                console.log(e)
                this.timeIndex1 = e.detail.value[0];
                this.timeIndex2 = e.detail.value[1];
                // this.time[1].splice(timeIndex1)
                this.time[1] = this.time[1].splice(this.timeIndex1 + 1)
                console.log(this.time[1])
                console.log(this.time[0][this.timeIndex1])
                console.log(this.time[1][this.timeIndex2])
                console.log(this.timeIndex1)
                console.log(this.timeIndex2)

            },
            aChange(e) {
                console.log(e)
                this.aaaIndex1 = e.detail.value;
                this.aaa2 = this.aaa2.splice(this.aaaIndex1 + 1)

            },
            aChange2(e) {
                console.log(e)
                this.aaaIndex2 = e.detail.value;
                // console.log(this.aaa2)
            },
            //推广码 显隐 函数
            codeSwitchChange: function (e) {
                if (e.target.value === true) {
                    this.isCode = true
                } else {
                    this.isCode = false
                }


            },
            //所属行业函数
            bindPickerChange: function (e) {
                console.log('picker发送选择改变，携带值为', e.target.value);
                this.index = e.target.value;
            },
            excludeSwitchChange: function (e) {
                console.log(e.target.value)
            },
            //区域位置函数
            toLocation(title) {
                this.location = title;
            },
            toEquipmentType(title) {
                this.equipmentType = title;
            },
            //多列选择 播放时间函数 
            showMulPicker() {
                this.mode = 'multiSelector';
                this.$refs.mpvueTimePicker.show();
            },
            // 三级联动选择 播放区域函数
            showMulLinkageThreePicker() {
                // this.deepLength = 3;
                this.mode = 'multiLinkageSelector';
                this.$refs.mpvueCityPicker.show();//在父组件中调用 mpvuePicker 实例中的 show 方法即可

            },
            //mpvue-picker 组件点击确定时回调，返回选中的 label, value 和数组索引 index 的值
            onConfirm(e) {
                // if (this.mode === 'multiSelector') {
                //     this.pickerTime = JSON.stringify(e.label)
                // } else if (this.model === 'multiLinkageSelector') {
                //     // this.pickerLocation = JSON.stringify(e.label)
                //      this.pickerLocation = JSON.stringify(e.label).replace(/^\"|\"$/g, '');

                // }

                this.pickerLocation = JSON.stringify(e.label).replace(/^\"|\"$/g, '')
                // console.log(this.pickerLocation)
                // console.log("onConfirm", e);
            },
            //日历  播放日期函数
            open1() {
                this.$refs.calendar1.open();
            },
            open2() {
                this.$refs.calendar2.open();

            },
            confirm1(e) {
                this.startTime = e.fulldate;
                console.log(e);
                if (this.endTime) {
                    var arr1 = this.startTime.split("-");
                    var arr2 = this.endTime.split("-");
                    var date1 = new Date(parseInt(arr1[0]), parseInt(arr1[1]) - 1, parseInt(arr1[2]), 0, 0, 0);
                    var date2 = new Date(parseInt(arr2[0]), parseInt(arr2[1]) - 1, parseInt(arr2[2]), 0, 0, 0);
                    if (date2.getTime() < date1.getTime()) {
                        uni.showToast({
                            title: '结束日期不能小于开始日期',
                            icon: 'none',
                            duration: 2000,
                            position: 'center'
                        });
                        this.startTime = "开始日期"
                        return false;
                    } else {
                        return true
                    }
                }
            },
            confirm2(e) {
                this.endTime = e.fulldate;
                console.log(e);
                var arr1 = this.startTime.split("-");
                var arr2 = this.endTime.split("-");
                var date1 = new Date(parseInt(arr1[0]), parseInt(arr1[1]) - 1, parseInt(arr1[2]), 0, 0, 0);
                var date2 = new Date(parseInt(arr2[0]), parseInt(arr2[1]) - 1, parseInt(arr2[2]), 0, 0, 0);
                if (date1.getTime() > date2.getTime()) {
                    uni.showToast({
                        title: '结束日期不能小于开始日期',
                        icon: 'none',
                        duration: 2000,
                        position: 'center'
                    });
                    this.endTime = "结束日期"
                    return false;
                } else {
                    return true;
                }
            },
            checkboxChange1: function (e) {
                var items = this.items1,
                    values = e.detail.value;
                for (var i = 0, len11 = items.length; i < len11; ++i) {
                    const item = items[i]
                    if (values.includes(item.value)) {
                        this.$set(item, 'checked', true)
                    } else {
                        this.$set(item, 'checked', false)
                    }
                }
                console.log(e)

            },
          


            checkboxChange2: function (e) {
                var items = this.items2,
                    values = e.detail.value;
                for (var i = 0, len2 = items.length; i < len2; ++i) {
                    const item = items[i]
                    if (values.includes(item.value)) {
                        this.$set(item, 'checked', true)
                    } else {
                        this.$set(item, 'checked', false)
                    }
                }


            },
            bindDateChange: function (e) {
                this.start_date = e.target.value

            },
            bindDateChange2: function (e) {
                this.end_date = e.target.value;
                this.other = this.end_date;
            },
            // 获取当前时间
            getDate(type) {
                const date = new Date();
                let year = date.getFullYear();
                let month = date.getMonth() + 1;
                let day = date.getDate();

                if (type === 'start') {
                    year = year - 60;
                } else if (type === 'end') {
                    year = year + 2;
                }


                month = month > 9 ? month : '0' + month;
                day = day > 9 ? day : '0' + day;

                return `${year}-${month}-${day}`;

            },
            formSubmit: function (e) {



                console.log('form发生了submit事件，携带数据为：', e.detail.value);



                // this.temp.name = e.detail.value.input1;
                // this.temp.trade_name = this.industry[e.detail.value.picker].name;
                // this.temp.trade_id = this.industry[e.detail.value.picker].id;
                // this.temp.producer = e.detail.value.input2;
                // this.temp.describe = e.detail.value.input3;

                // console.log(this.temp)
                //添加视频资源
                // const addVideo = {
                //     company: 'STQ',
                //     api: "pc_AdVideo_addVideo",
                //     version: '1.0',
                //     data: this.temp
                // };
                // socket.sendSocketMessage({
                //     data: JSON.stringify(addVideo)
                // });
                // _self.getData()


            },
            formReset: function (e) {
                console.log('清空数据');
            },
            getData(){
                socket.onSocketMessage(function (res) {
                    if (res !== '{"type":"ping"}') {
                        const resj = JSON.parse(res.data);
						if (resj.code === -1) {
							uni.showToast({
								title: resj.message,
								icon: 'none',
								duration: 2000,
								position: 'center'
							});
						} else{
                            if (resj.api === "pc_trade_index") {
								const list = []
								resj.data.map(item => {
									return list.push({ name: item.name, id: item.id.toString()});
									// return list.push(item.name)
								})
                                _self.total=resj.count
								_self.industry = list
								 console.log(resj.data)
								console.log(_self.industry)
							}
                        } 
                    }
                })
            }
        }

    }
</script>

<style>
    .header-nav {
        background-color: #F8F8F8;
        display: flex;
        flex: 1;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        text-align: center;
        width: 100%;
        height: 80upx;
        line-height: 80upx;
        font-size: 30upx;

    }

    .left-btn {
        display: flex;
        flex-direction: row;
        align-items: center;
    }

    .uni-form-item {
        display: flex;
        flex-direction: row;
        padding: 16upx 20rpx;
        font-size: 28rpx;
    }

    .uni-input {
        font-size: 28rpx;
    }

    .uni-form-item .title {
        width: 28%;
        font-size: 28rpx;
    }

    .location-row {
        width: 444upx;
        height: 50upx;
        border: 1px solid #007aff;
        border-radius: 10upx;
        display: flex;
        flex-direction: row;
    }

    .location-item {
        width: 33.3%;
        line-height: 50upx;
        text-align: center;
        border-right: 1px solid #007aff;
    }

    .location-active {
        background: #007aff;
        color: #ffffff;
    }

    .checkbox-label {
        float: left;
        width: 33%;
        height: 80upx;
        line-height: 80upx;
    }

    .checkbox-name {
        display: flex;
        flex-direction: row;
    }
</style>